//
//  Define_Basic.h
//  TYFoundationDemo
//
//  Created by tanyang on 15/12/23.
//  Copyright © 2015年 tanyang. All rights reserved.
//

#ifndef Define_Basic_h
#define Define_Basic_h

#ifdef __OBJC__

#endif

#ifdef DEBUG
#   define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#   define DLog(...)
#endif

// 弱引用
#define WEAK_REF(obj)\
__weak typeof(obj) weak_##obj = obj; \

// 是否ios7以上系统
#define kIsIOS7Later ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)

// ios8以上
#define kIsIOS8Later ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)

// 状态栏预留的高度
#define kHeightInViewForStatus (kIsIOS7Later ? 20 : 0)

// 状态条占的高度
#define kHeightForStatus 20

// 导航栏高度
#define kNavBarHeight 64

// 单元格高度
#define CellHeight 44

// 屏幕高度
#define kScreenHeight CGRectGetHeight([UIScreen mainScreen].bounds)

// 屏幕宽度
#define kScreenWidth CGRectGetWidth([UIScreen mainScreen].bounds)

// app高度
#define kApplicationHeight (kIsIOS7Later ? CGRectGetHeight([UIScreen mainScreen].bounds):CGRectGetHeight([[UIScreen mainScreen] applicationFrame]))

// 颜色 两种参数
#define RGB_255(r,g,b) [UIColor colorWithRed:(float)r/255.0 green:(float)g/255.0 blue:(float)b/255.0 alpha:1]

#define RGBA_255(r,g,b,a) [UIColor colorWithRed:(float)r/255.0 green:(float)g/255.0 blue:(float)b/255.0 alpha:a]

// 当前window
#define kCurrentWindow [[UIApplication sharedApplication].windows firstObject]

// 非空的字符串 避免输出null
#define kUnNilStr(str) ((str && ![str isEqual:[NSNull null]])?str:@"")

// 判断字符串等于空
#define JudgeStrEqualNull(judgeStrNull) (judgeStrNull == nil || judgeStrNull.length <= 0)

// 判断字符串不等于空
#define JudgeStrNotEqualNull(judgeStrNull) (judgeStrNull != nil && judgeStrNull.length > 0)

// 判断数组不等于空
#define JudgeArrayNotEqualNull(judgeArrayNull) (judgeArrayNull != nil && ![judgeArrayNull isKindOfClass:[NSNull class]] && judgeArrayNull.count != 0)

// app名称
#define kAppName [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]

// app版本
#define kAppVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]

// 全局绿色
#define GreenColor RGB_255(71,200,138)

// 加载xib
#define BundleXib(name) [[[NSBundle mainBundle] loadNibNamed:name owner:nil options:nil] firstObject]
#define BundleXib_Index(name,index)[[[NSBundle mainBundle] loadNibNamed:name owner:nil options:nil] objectAtIndex:index];

// 判断系统
#define iOS9 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0)

// 设置字体
//#define Text_Font(textSize) iOS9 ? [UIFont fontWithName:@"PingFangSC-Regular" size:textSize] :  [UIFont systemFontOfSize:textSize]
#define Text_Font(textSize) [UIFont systemFontOfSize:textSize]

// 单例
#undef    GPL_H_SINGLETON
#define GPL_H_SINGLETON( __class ) \
+ (__class *)sharedInstance;

#undef    GPL_M_SINGLETON
#define GPL_M_SINGLETON( __class ) \
+ (__class *)sharedInstance \
{ \
static dispatch_once_t once; \
static __class * __singleton__; \
dispatch_once( &once, ^{ __singleton__ = [[__class alloc] init]; } ); \
return __singleton__; \
}

// 提示框 alertView
#define alertView(Msg) [[[UIAlertView alloc] initWithTitle:@"提示" message:Msg delegate:nil cancelButtonTitle:@"确认" otherButtonTitles:nil]show]

#define alertView_delegate(Msg,Delegate,Tag) \
{ \
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:Msg delegate:Delegate cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil]; \
alertView.tag = Tag; \
[alertView show]; \
}

// 接口数据层
#define Infos respondObject
// code  1 成功 -1失败
#define RetCode respondObject[@"retcode"] == 1

#define LBXScan_Define_Native  //包含native库
#define LBXScan_Define_ZXing   //包含ZXing库
#define LBXScan_Define_ZBar   //包含ZBar库
#define LBXScan_Define_UI     //包含界面库

// 默认灰色
#define DefaultGray       RGB_255(104, 104, 104)
#define DefaultRadiusGray RGB_255(198, 198 ,198)

// 默认商品车
#define DefaultCommercial @"请扫描条码标签"
// 默认支架
#define DefaultStents     @"请扫描支架编号"
// 默认托盘
#define DefaultTray       @"请扫描托盘编号"
// 默认GPS
#define DefaultGPS        @"请扫码GPS编码"
// 默认钢铁托盘编号
#define DefaultSteelNo    @"钢铁托盘编号"
// 默认车辆支架编号
#define DefaultStentsNO   @"车辆支架编号"
// 集装箱提示语
#define ContainerPrompt   @"请输入集装箱编号"
// 商品车提示语
#define CommercialPrompt  @"请扫描商品车VIN码"
// 支架提示语
#define StentsPrompt      @"请扫描车辆支架编号"
// 托盘提示语
#define TrayPrompt        @"请扫描钢铁托盘编号"

// 临时测试使用的userId
#define TestUserId        @"101"

#endif /* Define_Basic_h */
